package cn.shyouchi.wuguanjia.android.ui.statistic;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.Global;
import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.widget.GlideCircleTransform;

/**
 * Created by Eenie on 2017/1/22 at 13:13
 * Email: 472279981@qq.com
 * Des:
 */

public class StatisticGroupIntegratedAdapter extends BaseMultiItemQuickAdapter<UserMonthRank, BaseViewHolder> {

    private String date;

    public StatisticGroupIntegratedAdapter(List<UserMonthRank> data) {
        super(data);
        addItemType(StatisticGroupAdapter.STATISTIC_INTEGRATED, R.layout.item_group_integrated_statistic_layout);
        date = "";

    }

    @Override
    protected void convert(BaseViewHolder holder, final UserMonthRank entity) {


        switch (entity.getItemType()) {
            case StatisticGroupAdapter.STATISTIC_INTEGRATED:




                if (holder.getAdapterPosition() == 0) {
                    ImageView flag= holder.getView(R.id.img_rank);
                    flag.setVisibility(View.VISIBLE);
                    flag.setImageResource(R.mipmap.ic_gold);
                    holder.getView(R.id.tv_rank_position).setVisibility(View.INVISIBLE);
                } else if (holder.getAdapterPosition() == 1) {
                    ImageView flag= holder.getView(R.id.img_rank);
                    flag.setVisibility(View.VISIBLE);
                    flag.setImageResource(R.mipmap.ic_silver);
                    holder.getView(R.id.tv_rank_position).setVisibility(View.INVISIBLE);
                } else if (holder.getAdapterPosition() == 2) {
                    ImageView flag= holder.getView(R.id.img_rank);
                    flag.setVisibility(View.VISIBLE);
                    flag.setImageResource(R.mipmap.ic_copper);
                    holder.getView(R.id.tv_rank_position).setVisibility(View.INVISIBLE);
                } else {
                    holder.getView(R.id.img_rank).setVisibility(View.INVISIBLE);
                    holder.getView(R.id.tv_rank_position).setVisibility(View.VISIBLE);
                    holder.setText(R.id.tv_rank_position, String.valueOf(holder.getAdapterPosition() + 1));
                }






                holder.setText(R.id.tv_name, String.format("%s", entity.getName() ));
                holder.setText(R.id.tv_rank_num, entity.getPermissions());
                ImageView img = holder.getView(R.id.img_header);
                loadHead(Global.BASE_URL + entity.getId_card_head_image(), img);
                break;

        }
    }


    private void loadHead(String path, ImageView imageView) {
        Glide.with(mContext)
                .load(path)
                .placeholder(R.mipmap.ic_default_header)
                .transform(new GlideCircleTransform(mContext))
                .into(imageView);
    }

    public void setDate(String date) {
        this.date = date;
    }
}
